<?php

/**
 * This file is part of the Pagizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Pagizer Core Team <team@pagizer.org>
 * @package     Pagizer
 * @subpackage  backoffice
 */

class m_backoffice_extends_Error extends f_exception_ErrorHandler
{
    public static function errorHandler($errno, $errmsg, $filename, $linenum, $vars)
	{
		$parameters = f_loader_Config::getInstance()->getParameters("default");
		$logger = f_logs_Logger::getInstance();

		$errorLevel = self::STRICT;

		if(isset($parameters['errorLevel']) && defined('self::'.strtoupper($parameters['errorLevel'])))
		{
			$errorLevel = constant('self::'.strtoupper($parameters['errorLevel']));
		}

		switch ($errno)
		{
		    case E_NOTICE:
		    	$logger->noticeLog($filename." (ln.".$linenum.") - ".$errmsg);
		    break;

		    default:
		    	if($errorLevel > 100)
		    	{
		    		$logger->errorLog($filename." (ln.".$linenum.") - ".$errmsg);
		    		$error = new ErrorException($errmsg, 5, 0, $filename, $linenum);
		    		throw new Exception($error);
		    	}
		    break;
		}
	}
}
